<?php require_once 'header.php';
require_once 'OwnerPage.php';
require_once 'backend/Item.php';
$item = new Item();
?>

	<form action="Items.php" method="post">
	  <fieldset>
	  <legend> Current Menu</legend>
	  <p/>
	  <legend>Appetizers</legend>
	  <?php 
	  
	 	$result = $item->getAllAppetizers();
	 	$item->DisplayItems($result);
	  ?>
	  <p/>
	  <legend>Soups</legend>
	  <?php 
	  
	 	$result = $item->getAllSoups();
	 	$item->DisplayItems($result);
	  ?>
	  <p/>
	  <legend>Salads</legend>
	  <?php 
	  
	 	$result = $item->getAllSalads();
	  	$item->DisplayItems($result);
	  	
	  	if (isset($_POST['SetNotAvaliable']))
	  	{
	  		$selectitem = $_POST['ITM'];
	  		$item->setItemtoNotAvaliable($selectitem);
	  		?>
	  		<script language="JavaScript">window.location.href="Items.php"</script>
	  		<?php
	  		
	  	}
	  	if (isset($_POST['SetAvaliable']))
	  	{
	  		$selectitem = $_POST['ITM'];
	  		$item->setItemavaliable($selectitem);
	  		?>
	  		<script language="JavaScript">window.location.href="Items.php"</script>
	  		<?php
	  	}
	  	if (isset($_POST['Changeprice']))
	  	{
	  		$newPrice = $_POST['newPrice'];
	  		$selectitem = $_POST['ITM'];
	  		$item->changeitemprice($selectitem,$newPrice);
	  		?>
	  		<script language="JavaScript">window.location.href="Items.php"</script>
	  		<?php
	  	}
	  ?>
	  <p>
	  New Price: <input type="text" name="newPrice"/>
	  <input type="submit" name= "Changeprice" value ="Change Price"/>
	  <input type="submit" name= "SetAvaliable" value = "Set Avaliable"/>
	  <input type="submit" name= "SetNotAvaliable" value = "Set Unavaliable"/>
	  </p>
	  </fieldset>
	</form>
	<form action="Items.php" method="post">
	  <fieldset>
	  <legend>New Item</legend>
	  <?php 
	  	if(isset($_POST['Name']))
	  	{
	  		$name = ($_POST['Name']);
	  		$category = ($_POST['Category']);
	  		$price = ($_POST['Price']);
	  		$description = ($_POST['Description']);
	  		if($name == "" || $category == "" || $price == "" || $description == "")
			{
				echo "<font size=3 color=red><b>Not all fields were entered</b><p/></font><br/>";
			}
	  		else
			{
				$item = new Item();
				$result = $item->addItem($name, $category, $price, $description);
					
				if($result == "1")
				{
					echo "Item Added Successfully";
				}
				else 
				{
					echo "Item could not be added at this time.";
				}
			}
	  	}
	  ?>
	  <br><br>
		<div id = "Name">
			<font size = "3">Name : <p/></font>
			<input  name="Name" type="text">
			<p/>
		</div>
		
		<div id = "Category">
		<font size = "3">Category : <p/></font>
			<select name = "Category">
			<option value='Appetizers'>Appetizers</option>
			<option value='Salads'>Salads</option>
			<option value='Soups'>Soups</option>
			</select>
	        
		</div>
		
		<div id = "Price">
			<font size = "3">Price : <p/></font>
			<input  name="Price" type="text" >
		</div>
		
		<div id ="Description">
			<font size = "3">Description : <p/></font>
			<input type="text" name='Description' />
		</div>
		
		<p><input type="submit" value="Add Item" />
		<input type='reset' value='Clear'/>
	  </fieldset>
	  </form>
	</div>


<?php require_once 'footer.php';?>